/**
 *    Copyright (C) 2008, 2009  Victor Smirnov <aist11@gmail.com>
 *
 *    This program is free software; you can redistribute it and/or modify
 *    it under the terms of the GNU General Public License as published by
 *    the Free Software Foundation; either version 3 of the License, or
 *    (at your option) any later version.
 *
 *    This program is distributed in the hope that it will be useful,
 *    but WITHOUT ANY WARRANTY; without even the implied warranty of
 *    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *    GNU General Public License for more details.
 *
 *    You should have received a copy of the GNU General Public License along
 *    with this program; if not, write to the Free Software Foundation, Inc.,
 *    51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
 *
 *    See LICENSE.exceptions in the root folder of this project for possible
 *    exceptions
 *
 */

#ifndef _CUBEFS_CORE_BTREE_MACROS_HPP
#define	_CUBEFS_CORE_BTREE_MACROS_HPP

#define CUBEFS_BTREE_MODEL_BASE_CLASS_NO_CTOR_BEGIN(BTreeModelBaseClassName)            \
template <                                                                              \
        typename Profile,                                                               \
        typename MyType,                                                                \
        typename TypesType,                                                             \
        typename ModelTypeName>                                                         \
class BTreeModelBaseClassName: public ModelBase<                                        \
                                        Profile,                                        \
                                        MyType,                                         \
                                        TypesType,                                      \
                                        ModelTypeName> {                                \
                                                                                        \
    typedef ModelBase<Profile, MyType, TypesType, ModelTypeName>                Base;   \
                                                                                        \
    MyType&                     me_;                                                    \
                                                                                        \
public:

#define CUBEFS_BTREE_MODEL_BASE_CLASS_BEGIN(BTreeModelBaseClassName)                    \
    CUBEFS_BTREE_MODEL_BASE_CLASS_NO_CTOR_BEGIN(BTreeModelBaseClassName)                \
                                                                                        \
    BTreeModelBaseClassName(MyType &me): Base(me), me_(me) {}                           \
                                                                                        \
    MyType &me() {                                                                      \
        return me_;                                                                     \
    }                                                                                   \
                                                                                        \
    const MyType &me() const {                                                          \
        return me_;                                                                     \
    }


#define CUBEFS_BTREE_MODEL_BASE_CLASS_END };



#define CUBEFS_BTREE_MODEL_BASE_FACTORY(ProfileName, ModelTypeName, ClassName)  \
template <                                                                      \
        typename Profile,                                                       \
        typename MyType,                                                        \
        typename TypesType,                                                     \
        typename Default                                                        \
>                                                                               \
class TypeFactory<                                                              \
        ProfileName,                                                            \
        Profile,                                                                \
        BTreeModelBaseFactoryName<                                              \
            Profile,                                                            \
            MyType,                                                             \
            TypesType,                                                          \
            ModelTypeName                                                       \
        >,                                                                      \
        Default>  {                                                             \
public:                                                                         \
    typedef ClassName<Profile, MyType, TypesType, ModelTypeName>                Type;   \
};



#define CUBEFS_BTREE_ITERATOR_BASE_CLASS_NO_CTOR_BEGIN(BTreeIteratorBaseClassName)\
template <                                                                      \
        typename Profile,                                                       \
        typename MyType,                                                        \
        typename ModelType														\
>                                                                               \
class BTreeIteratorBaseClassName: public IteratorBase<                   		\
        Profile,                                                                \
        MyType,                                                                 \
        ModelType>                                                    			\
{                                                                               \
    MyType&             me_;                                                    \
    typedef IteratorBase<Profile, MyType, ModelType> 							Base;


        
#define CUBEFS_BTREE_ITERATOR_BASE_CLASS_BEGIN(BTreeIteratorBaseClassName)      \
CUBEFS_BTREE_ITERATOR_BASE_CLASS_NO_CTOR_BEGIN(BTreeIteratorBaseClassName)      \
    BTreeIteratorBaseClassName(MyType &me): Base(me), me_(me) {}


#define CUBEFS_BTREE_ITERATOR_BASE_CLASS_END };

#endif
